#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#

import socket

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s1 = server.bind(("127.0.0.1", 1999), )
server.settimeout(5)
server.listen(1)
conn, addr = server.accept()

while True:
    print(conn)
    client_data = conn.recv(1024).decode("utf-8")
    print(client_data)
    print(addr)
    if client_data.strip() == "exit":
        exit("通信结束")
    conn.sendall("world".encode("utf-8"))

conn.close()
